﻿using FastCreateProject.Helpers;
using System.Text;
using System.Web;

namespace FastCreateProject.Controllers.Lv0
{
    public class HomeController: Controller
    {
        public HttpResponseActionModel Index(ControllerOption option, string args, HttpRequestModel httpRequest)
        {
            var rsp = ResponseBase<object>.Failed2();
            try
            {
                var body = HttpUtility.UrlDecode(httpRequest.Body);
                switch (args.ToLower())
                {
                    default:
                        {
                            throw new WithCodeException((int)ErrorCodeEnum.InvalidArguments, $"无效的参数：{args}");
                        }
                    case "create":
                        {
                            rsp.body = "1.zip";
                            break;
                        }
                }

                rsp.error_code = null;
                rsp.error_message = null;
                rsp.error_message_debug = null;
            }
            catch (WithCodeException wcex)
            {
                rsp.error_code = wcex.Code;
                rsp.error_message = wcex.Message;
            }
            catch (Exception ex)
            {
                LogHelper.WriteAsync(ex.ToString());
            }

            return Json(rsp);
        }
    }
}